package com.qingzhu.dao.impl;

import com.qingzhu.dao.EditionDao;
import com.qingzhu.pojo.Edition;
import com.qingzhu.util.CreateSqlSessionFactory;
import org.apache.ibatis.session.SqlSession;

public class EditionDaoImpl implements EditionDao {
    @Override
    public Edition findEditionFromMemory(int runMemoryId, int fuselageMemoryId) {
        try (SqlSession sqlSession = CreateSqlSessionFactory.getFactory().openSession(true)) {
            EditionDao editionDao = sqlSession.getMapper(EditionDao.class);
            return editionDao.findEditionFromMemory(runMemoryId,fuselageMemoryId);
        }
    }

    @Override
    public Edition findEditionFromName(String editionName) {
        try (SqlSession sqlSession = CreateSqlSessionFactory.getFactory().openSession(true)) {
            EditionDao editionDao = sqlSession.getMapper(EditionDao.class);
            return editionDao.findEditionFromName(editionName);
        }
    }
}
